import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete, HttpStatus, HttpException, HttpCode, Query, Put, Ip
} from "@nestjs/common";
import { UsersService } from './users.service';
import { CreateUserDto } from './dto/create-user.dto';
import { UpdateUserDto } from './dto/update-user.dto';
import { FindUserDTO } from "./dto/find-user.dto";
import { DeleteUserDto } from "./dto/delete-user.dto"

@Controller('users')
export class UsersController {
  constructor(private readonly usersService: UsersService) {}

  //新增用户
  @Post()
  @HttpCode(HttpStatus.OK)
  create(@Body() createUserDto: CreateUserDto, @Ip() ip:string) {
    return this.usersService.create(createUserDto,ip);
  }

  @Get()
  findAll(@Query() findUserDto: FindUserDTO) {
    return this.usersService.findAll(findUserDto);
  }

  @Get(':id')
  findOne(@Param('id') id: string) {
    return this.usersService.findOne(+id);
  }

  @Put()
  update(@Body() updateUserDto: UpdateUserDto) {
    return this.usersService.update(updateUserDto);
  }
  @Delete()
  remove(@Body() deleteUserDto: DeleteUserDto) {
    return this.usersService.remove(deleteUserDto);
  }
}